import Global from './global'

export default {
  // 英文模版 smType = 0
  getEnScript(name, sId) {
    var smScript = []
    smScript.push('{$I 组件调试.run}')
    smScript.push('')
    smScript.push('{$I 输入模板.run}')
    smScript.push(Global.strFormat('{0}()', name))
    smScript.push('')
    smScript.push('{$I 帮助信息.run}')
    smScript.push('')
    smScript.push('{$I 函数主体.run}')
    smScript.push(Global.strFormat('function main_{0}(const s: string): boolean;', sId))
    smScript.push('begin')
    smScript.push('  Result := True;')
    smScript.push('  trace(s);')
    smScript.push('end;')
    smScript.push('')
    smScript.push('{$I 调试开始.run}')
    smScript.push(Global.strFormat("main_{0}('参数');", sId))
    smScript.push('{$I 调试结束.run}')
    return smScript.join('\r\n')
  },
  // LinuxShell模板 smType = 1
  getLinuxShellScript(name) {
    var smScript = []
    // smScript.push(strFormat('{0}()', name));
    smScript.push('#!/bin/sh')
    smScript.push('basepath=$(cd `dirname $0`; pwd -P)')
    smScript.push('AgentFunc=${basepath}"/AgentFunc.sh"')
    smScript.push('ServerFunc=${basepath}"/ServerFunc.sh"')
    smScript.push('.  $AgentFunc')
    smScript.push('.  $ServerFunc')
    smScript.push('')
    smScript.push('value=""')
    smScript.push('level="Normal" # "Normal" "Offline" "Unknown" "Hint" "Warning" "Secondary" "major" "Error"')
    smScript.push('notes=""')
    smScript.push('# shell script')
    smScript.push('')
    smScript.push('echo "Shell"')
    smScript.push('value=`cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c`')
    smScript.push('')
    smScript.push('# return')
    smScript.push('echo "value[$value]"')
    smScript.push('echo "level[$level]"')
    smScript.push('echo "notes[$notes]"')
    return smScript.join('\r\n')
  },
  // 中文模板 smType = 2
  getCnScript(name) {
    var smChinese = []
    smChinese.push('{$I 输入模板.run}')
    smChinese.push(Global.strFormat('{0}()', name))
    smChinese.push('')
    smChinese.push('{$I 帮助信息.run}')
    smChinese.push('')
    smChinese.push('{$I 参数定义.run}')
    smChinese.push('参数:字符串')
    smChinese.push('{$I 返回定义.run}')
    smChinese.push('返回:字符串')
    smChinese.push('{$I 函数主体.run}')
    smChinese.push('')
    smChinese.push('返回 = 设置指标(\'正常\', \'数据\', \'描述\')')
    smChinese.push('Trace(返回)')
    smChinese.push('{$I 调试开始.run}')
    smChinese.push('调用组件(\'参数1\')')
    smChinese.push('{$I 调试结束.run}')
    return smChinese.join('\r\n')
  },
  // AutoIT模板 smType = 3
  getAutoITScript(name) {
    var smScript = []
    // smScript.push(strFormat('{0}()', name));
    smScript.push('#{DEFINE WIN32}')
    smScript.push(';#NoTrayIcon')
    smScript.push('#include <Constants.au3>')
    smScript.push('; $CmdLine[1] 中文脚本调用组件,对应参数1...')
    smScript.push('')
    smScript.push('')
    smScript.push('; Finished! 中文脚本调用组件,以下是返回')
    smScript.push('; SetTarget("严重", "数据", "描述")')
    return smScript.join('\r\n')
  },
  // Python模板 smType = 5
  getPythonScript(name) {
    var smScript = []
    smScript.push('# encoding:gbk')
    smScript.push('')
    smScript.push('import AomScript')
    smScript.push('')
    smScript.push('value=""')
    smScript.push('level="Normal" # "Normal" "Offline" "Unknown" "Hint" "Warning" "Secondary" "major" "Error"')
    smScript.push('notes=""')
    smScript.push('# python script')
    smScript.push('')
    smScript.push('# return')
    smScript.push('print "value[%s]" %value')
    smScript.push('print "level[%s]" %level')
    smScript.push('print "notes[%s]" %notes')
    return smScript.join('\r\n')
  },
  // PowerShell模板 smType = 6
  getPowerShellScript(name) {
    var smScript = []
    smScript.push('#"Normal" "Offline" "Unknown" "Hint" "Warning" "Secondary" "major" "Error"')
    smScript.push('$value = ""')
    smScript.push('$level = "Normal"')
    smScript.push('$notes = ""')
    smScript.push('#script')
    smScript.push('')
    smScript.push('#return')
    smScript.push('"value[$value]"')
    smScript.push('"level[$level]"')
    smScript.push('"notes[$notes]"')
    return smScript.join('\r\n')
  },
  // Perl模板 smType = 7
  getPerlScript(name) {
    var smScript = []
    smScript.push('$value="";')
    smScript.push('$level="Normal"; # "Normal" "Offline" "Unknown" "Hint" "Warning" "Secondary" "major" "Error"')
    smScript.push('$notes="";')
    smScript.push('# perl script')
    smScript.push('')
    smScript.push('# return')
    smScript.push('printf("value[%s]\n", $value);')
    smScript.push('printf("level[%s]\n", $level);')
    smScript.push('printf("notes[%s]\n", $notes);')
    return smScript.join('\r\n')
  },
  // Bat模板 smType = 8
  getBatScript(name) {
    var smScript = []
    smScript.push('@echo off')
    smScript.push(':: "Normal" "Offline" "Unknown" "Hint" "Warning" "Secondary" "major" "Error"')
    smScript.push('set value=数据')
    smScript.push('set level=Normal')
    smScript.push('set notes=描述')
    smScript.push(':: script')
    smScript.push('')
    smScript.push(':: return')
    smScript.push('echo value[%value%]')
    smScript.push('echo level[%level%]')
    smScript.push('echo notes[%notes%]')
    return smScript.join('\r\n')
  },
  // JS模板 smType = 9
  getJSScript(name) {
    var smScript = []
    smScript.push('function main(){')
    smScript.push('	var value = "";')
    smScript.push('	var level = "Normal"; // "Normal" "Offline" "Unknown" "Hint" "Warning" "Secondary" "major" "Error"')
    smScript.push('	var notes = "";')
    smScript.push('	// script')
    smScript.push('')
    smScript.push('	// return')
    smScript.push('	console.log("value[" + value + "]")')
    smScript.push('	console.log("level[" + level + "]")')
    smScript.push('	console.log("notes[" + notes + "]")')
    smScript.push('}')
    smScript.push('main();')
    return smScript.join('\r\n')
  },
  // VBS模板 smType = 10
  getVBSScript(name) {
    var smScript = []
    smScript.push('\' "Normal" "Offline" "Unknown" "Hint" "Warning" "Secondary" "major" "Error"')
    smScript.push('dim value')
    smScript.push('dim level')
    smScript.push('dim notes')
    smScript.push('level = "Normal"')
    smScript.push('\' script')
    smScript.push('')
    smScript.push('\' return')
    smScript.push('WSH.Echo "value[" + value + "]"')
    smScript.push('WSH.Echo "level[" + level + "]"')
    smScript.push('WSH.Echo "notes[" + notes + "]"')
    return smScript.join('\r\n')
  }
}
